﻿namespace Data.OdpNet.QuickStarts.Console
{
    using System;
    using System.Data;
    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
    using Microsoft.Practices.EnterpriseLibrary.Data;

    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var database = EnterpriseLibraryContainer.Current.GetInstance<Database>();

                using (var reader = database.ExecuteReader(CommandType.Text, "Select * from Region"))
                {
                    while (reader.Read())
                    {
                        Console.WriteLine("Reading region {0}: {1}", reader[0], reader[1]);
                    }
                }
            }
            catch (Exception ex)
            {

                Console.WriteLine("Something went wrong{0}{1}", Environment.NewLine, ex);
            }

            Console.WriteLine("Press a key to exit");
            Console.ReadKey();
        }
    }
}
